package pers.xhh.frontapi.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import pers.xhh.frontapi.common.Mi;
import pers.xhh.frontapi.service.MiGoodsService;

/**
 * @author wei-xhh
 * @date 2020-11-26
 */
@CrossOrigin
@RestController
@RequestMapping("/mi/api")
public class MiGoodsController {

    @Autowired
    MiGoodsService miGoodsService;

    @GetMapping("/goods")
    public Mi listGoods(@RequestParam(required = false) String query,
                        @RequestParam(required = false) Integer cateOneId,
                        @RequestParam Integer pagenum,
                        @RequestParam Integer pagesize) {
        return miGoodsService.listGoods(query, cateOneId, pagenum, pagesize);
    }

    @GetMapping("/goods/{id}")
    public Mi getGoodsById(@PathVariable("id") Integer id) {
        return miGoodsService.getGoodsById(id);
    }


}
